from selenium import webdriver
from time import sleep

if __name__ == "__main__":
    bro = webdriver.Chrome(executable_path='./chromedriver')
    # 隐性等待，最长等20秒
    bro.implicitly_wait(20)
    # 发起HTTP请求
    bro.get('https://qzone.qq.com/')
    # 如果定位的标签存在于iframe标签里，则必须切换浏览器标签定位的作用域
    bro.switch_to.frame('login_frame')
    a_tag = bro.find_element_by_id("switcher_plogin")
    a_tag.click()

    username_tag = bro.find_element_by_id("u")
    password_tag = bro.find_element_by_id("p")

    username_tag.send_keys("110")
    sleep(0.5)
    password_tag.send_keys("123")
    sleep(0.5)

    btn = bro.find_element_by_id("login_button")
    btn.click()

    sleep(3)
    # 关闭浏览器
    bro.quit()
